﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using WindowsPhoneApp;

namespace WindowsPhoneAppHost
{
    public partial class ControlPanel : UserControl
    {
        public string RefreshEvent{get;set;}
        public string SearchEvent{get;set;}
        public string PrePageEvent{get;set;}
        public string NextPageEvent{get;set;}

        private int currentPage;
        public int CurrentPage
        {
            get{return this.currentPage;}
            set
            {
                this.currentPage = value;
                changeText();
            }
        }
        private int totalPage;
        public int TotalPage
        {
            get { return this.totalPage; }
            set
            {
                this.totalPage = value;
                changeText();
            }
        }

        public ControlPanel()
        {
            InitializeComponent();
        }

        private void changeText()
        {
            textBlock.Text = currentPage.ToString() + "/" + totalPage.ToString();
        }

        private void refresh_Button_Click(object sender, RoutedEventArgs e)
        {
            Common.executePageMethod(RefreshEvent, sender, e);
        }

        private void search_Button_Click(object sender, RoutedEventArgs e)
        {
            Common.executePageMethod(SearchEvent, sender, e);
        }

        private void prePage_Button_Click(object sender, RoutedEventArgs e)
        {
            Common.executePageMethod(PrePageEvent, sender, e);
        }

        private void nextPage_Button3_Click(object sender, RoutedEventArgs e)
        {
            Common.executePageMethod(NextPageEvent, sender, e);
        }
    }
}
